package demo1;

import javax.swing.plaf.synth.SynthOptionPaneUI;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-11-28
 * Time: 19:08
 */
public class Account {
    public void begining(){
        System.out.println("打开系统进行操作!");
    }
    public void ending(){
        System.out.println("退出系统！");
    }
    public void useAccount(BankAccount bankAccount){
        bankAccount.accountName();
        if (bankAccount instanceof Deposit) {
            begining();
            Deposit deposit = (Deposit) bankAccount;
            deposit.input1();

        } else if (bankAccount instanceof Withdrawal) {
            begining();
            Withdrawal withdrawal = (Withdrawal) bankAccount;
            withdrawal.input2();
        }else {
            ending();
        }
    }

    public static void main(String[] args) {
        Account account = new Account();
        account.useAccount(new Deposit());
        System.out.println("=============");
        account.useAccount(new Withdrawal());
    }
}
